package com.wyh.socket_demo.controller;

import com.wyh.socket_demo.entiy.Result;
import com.wyh.socket_demo.service.FileStreamAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wyh
 * @version 1.0
 * @date 2022/4/8 16:50
 */
@RestController
public class Controller {

    @Autowired
    private FileStreamAdapter fileStreamAdapter;

    @GetMapping("/FileStream/{pdfId}")
    public Result FileStream(@PathVariable("pdfId") Integer pdfId){
        String pdfPath = null;
        if (pdfId == 1){
            pdfPath ="https://yhyunwork-1259477837.cos.ap-shanghai.myqcloud.com/yhyunwork/2022/4/0/printTest.pdf2022-04-0670.pdf";
        }
        String fileRead = fileStreamAdapter.UrlFileRead(pdfPath);
        pdfPath = "https://yhyunwork-1259477837.cos.ap-shanghai.myqcloud.com/yhyunwork/2022/4/1/baodan.pdf2022-04-1198.pdf";
        String fileRead2 = fileStreamAdapter.UrlFileRead(pdfPath);

        Map<String, Object> map = new HashMap<>();
        map.put("first",fileRead);
        map.put("second",fileRead2);
        return new Result(map);
    }

}
